<template>
    <div id="all"> 
        <router-link to="/">
            <span class="fa fa-close"></span>
        </router-link>
        <router-link to="/second/User">
            <div id="top">
                <span class="fa fa-angle-up"></span>
                <p>没有账号，去注册</p>
            </div>
        </router-link>
        <div id="login">
            <input type="text" placeholder="请输入用户名" v-model="username">
            <input type="password" placeholder="密码4~12位字符" v-model="psw">
            <button @touchstart="loginBtn">登录</button>
        </div>
        <div id="other">
            <hr>
            <span>或用以下方式登录</span>
            <hr>
        </div>
        <div id="third">
            <div class="item"> 
                <span class="fa fa-weixin"></span>
                <p>微信登录</p>
            </div>
            <div class="item">
                <span class="fa fa-weibo"></span>
                <p>微博登录</p>
            </div>
            <div class="item">
                <span class="fa fa-qq"></span>
                <p>QQ登录</p>
            </div>
        </div>
    </div>
</template>

<script>
export default{
    data:function(){
        return{
            username:"",
            psw:""
        }
    },
    methods:{
        loginBtn:function(){
            if(this.username==""||this.psw==""){
                layer.msg("请输入用户名或密码");
                return;
            }
            var params = {
                username:this.username,
                psw:this.psw
            }
            this.$store.dispatch("requestLogin",params).then(res=>{
                layer.msg(res.data.msg);
                if(!res.data.err){
                    this.$store.commit("setUserInfo",res.data.userInfo);
                    location.href = "#/second/User"
                }
            })
            this.username = "";
            this.psw = "";
        }
    },
}
</script>

<style scoped>
    #all{
        background: white;
    }
    a{
        text-decoration: none;
        color: black;
    }
    .fa-close{
        position: absolute;
        font-size: 25px;
        left: 8px;
        top: 8px;
    }
    #top{
        text-align: center;
    }
    #top span{
        font-size: 30px;
    }
    #top p{
        margin: 0;
        font-size: 15px;
        font-weight: 500;
    }
    #login{
        width: 80%;
        margin: 0 auto;
        margin-top: 180px;
    }
    #login input{
        width: 100%;
        border-top: none;
        border-right: none;
        border-left: none;
        border-bottom: 1px solid red;
        margin-bottom: 35px;
        font-size: 15px;
    }
    button{
        width: 100%;
        height: 35px;
        color: white;
        font-size: 16px;
        background-color: #FF3030;
    }
    #other{
       display: flex;
       width: 80%;
       margin: 0 auto;
       text-align: center;
       margin-top: 50px;
    }
    #other span{
        font-size: 12px;
        font-family: 宋体;
    }
    hr{
        width: 30%;
        display: inline-block;
    }
    #third{
        display: flex;
        justify-content: space-around;
        width: 80%;
        margin-left: 30px;
        margin-top: 35px;
    }
    .item{
        text-align: center;
    }
    .item span{
        font-size: 30px;
    }
    .item p{
        margin: 0;
        font-size: 14px;
    }
</style>